package Test;


public class DeathLock {

    /**
     * death lock
     * @param args
     */
    public static void main(String[] args) {
        String s1 = new String("1111");
        String s2 = new String("2222");
        String s3 = new String("3333");
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    synchronized (s1){
                        Thread.sleep(100);
                        System.out.println("---"+Thread.currentThread()+"---");
                        synchronized (s2){

                        }
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"thread---1").start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    synchronized (s2){
                        Thread.sleep(100);
                        System.out.println("---"+Thread.currentThread()+"---");
                        synchronized (s3){

                        }
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"thread---2").start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    synchronized (s3){
                        Thread.sleep(500);
                        System.out.println("---"+Thread.currentThread()+"---");
                        synchronized (s1){

                        }
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"thread---3").start();
    }
}
